from typing import List


class Solution:
    def isValidSudoku(self, board: List[List[str]]) -> bool:
        for i in range(9):
            st = [False] * 10
            for j in range(9):
                if board[i][j] != '.':
                    t = int(board[i][j]) - 1
                    if st[t]:
                        return False
                    st[t] = True


        for i in range(9):
            st = [False] * 10
            for j in range(9):
                if board[j][i] != '.':
                    t = int(board[j][i]) - 1
                    if st[t]:
                        return False
                    st[t] = True

        for i in range(0, 9, +3):
            for j in range(0, 9, +3):
                st = [False] * 10
                for n in range(3):
                    for m in range(3):
                        if board[i + n][j + m] != '.':
                            t = int(board[i + n][j + m]) - 1
                            if st[t]:
                                return False
                            st[t] = True
        return True


s = [
["5","3",".",".","7",".",".",".","."],
["6",".",".","1","9","5",".",".","."],
[".","9","8",".",".",".",".","6","."],
["8",".",".",".","6",".",".",".","3"],
["4",".",".","8",".","3",".",".","1"],
["7",".",".",".","2",".",".",".","6"],
[".","6",".",".",".",".","2","8","."],
[".",".",".","4","1","9",".",".","5"],
[".",".",".",".","8",".",".","7","9"]
]

print(Solution().isValidSudoku(s))